package com.lzy.cloud.job.service.impl;

import com.lzy.cloud.job.dtos.JobInfoDto;
import com.lzy.cloud.job.entity.JobInfo;
import com.lzy.cloud.job.mapper.JobInfoMapperExt;
import com.lzy.cloud.job.service.JobInfoService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobInfoServiceImpl implements JobInfoService {

    @Autowired
    private JobInfoMapperExt jobInfoMapperExt;
    /**
     * 获取所有的任务信息
     *
     * @return
     */
    @Override
    public List<JobInfoDto> getAllJobs() {
        return jobInfoMapperExt.getAllJobs();
    }

    /**
     * 增加任务
     *
     */
    @Override
    public Boolean insertJob(JobInfoDto jobInfoDto){
        return jobInfoMapperExt.insertSelective(DozerUtils.map(jobInfoDto,JobInfo.class)) > 0;
    }

    /**
     * 修改任务
     *
     */
    @Override
    public Boolean updateJob(JobInfoDto jobInfoDto) {
        return jobInfoMapperExt.updateByPrimaryKeySelective(DozerUtils.map(jobInfoDto,JobInfo.class)) > 0;
    }

    /**
     * 删除任务
     *
     */
    @Override
    public Boolean deleteJob(Integer id) {
        return jobInfoMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public JobInfoDto findById(Long id) {
        return jobInfoMapperExt.findById(id);
    }
}
